<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2019/11/20
 * Time: 14:30
 */

namespace app\common\service;


class IpsConfig
{
    /**
     * @name: 查询
     * @Param: 
     * @Description: 
     * @Author: wx
     * @Date: 2019-12-09 17:06:14
     */
    function findData($condition)
    {
        return db('ips_config')->where($condition)->find();
    }

    /**
     * @name: 添加
     * @Param: 
     * @Description: 
     * @Author: wx
     * @Date: 2019-12-09 17:06:32
     */
    function add($data)
    {
        if(db('IpsConfig')->where('host_id', $data['host_id'])->count() > 0)
        {
            return [];
        }
        
        db('IpsConfig')->insert($data);
    }

    /**
     * @name: 删除
     * @Param: 
     * @Description: 
     * @Author: foo
     * @Date: 2019-12-24 13:21:31
     */
    function del ($host_id_a)
    {
        db('IpsConfig')->whereIn('host_id', $host_id_a)->delete();
    }

    /**
     * @name: 修改
     * @Param: 
     * @Description: 
     * @Author: wx
     * @Date: 2019-12-09 17:07:34
     */
    function modify($condition, $data)
    {
        return db('ips_config')->where($condition)->update($data);
    }

    /**
     * @name: 查询列表
     * @Param: 
     * @Description: 
     * @Author: foo
     * @Date: 2020-01-06 11:45:54
     */
    function selectByHostId($host_id_a, $field = '*')
    {
        $return = db('IpsConfig')->field($field) ->whereIn('host_id', $host_id_a)->select();

        return $return;
    }
}